package com.whzykj.model;

import com.jfinal.plugin.activerecord.Model;
import com.whzykj.jfinal.TableBind;

@TableBind(name="customer",pk="cust_id")
public class Customer extends Model<Customer>{
	private static final long serialVersionUID = 1L;
	public static final Customer dao=new Customer();
	
	/**
	 * 查询指定电话号码的客户是否存在
	 * @param mobile
	 * @return true:存在；false：表示不存在
	 */
	public boolean findExistsCustomer(String mobile){
		boolean res=false;
//		String sql="select * from customer WHERE MOBILE='"+mobile+"'";
		StringBuffer sql=new StringBuffer(" SELECT cust.MOBILE from customer cust WHERE cust.MOBILE=?");
		sql.append(" UNION");
		sql.append(" select ui.MOBILE from userinfo ui where ui.MOBILE=?");
		Customer customer=Customer.dao.findFirst(sql.toString(),mobile,mobile);
		if(customer==null){
			res=false;
		}else{
			res=true;
		}
		return res;
	}
}
